﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace itau.imnk.entidades
{
    public static class EntidadeFactory
    {
        public static Yield GetYield(DataRow dataRow)
        {
            return new Yield()
            {
                CodigoYield = Conversor.ConverterParaInt(dataRow["CD_YIELD"]),
                CodigoOperador = Conversor.ConverterParaString(dataRow["CD_OPERADOR"]),
                CodigoTipoYield = Conversor.ConverterParaString(dataRow["CD_TIPO_YIELD"]),
                DataHoraGravacaoCustos = Conversor.ConverterParaDateTime(dataRow["DTHR_GRVCUSTOS"]),
                DataReferencia = Conversor.ConverterParaDateTime(dataRow["DT_REFERENCIA"]),
                DataRegistroHistorico = Conversor.ConverterParaDateTime(dataRow["DT_REG_HISTORICO"]),
                DataUltimaAlteracao = Conversor.ConverterParaDateTime(dataRow["DT_ULT_ALT"]),
                IndiceFechamento = Conversor.ConverterParaInt(dataRow["IC_FECHAMENTO"]),
                NomeMesa = Conversor.ConverterParaString(dataRow["NM_MESA"]),
                NomeSubmesa = Conversor.ConverterParaString(dataRow["NM_SUBMESA"]),
                NomeYield = Conversor.ConverterParaString(dataRow["NM_YIELD"]),
                QuantidadeFuturosLiquidos = Conversor.ConverterParaInt(dataRow["NU_QTDE_FUT_LIQUIDOS"]),
                QuantidadeSwapCalculado = Conversor.ConverterParaInt(dataRow["NU_QTDE_SWAP_LIQUIDOS"]),
                QuantidadeSwapLiquidos = Conversor.ConverterParaInt(dataRow["NU_QTDE_SWAP_CALCULO"]),
                TipoCalculo = Conversor.ConverterParaChar(dataRow["TP_CALCULO"]),
                Versao = Conversor.ConverterParaInt(dataRow["NU_VERSAO"])
            };
        }

        public static CurvaNK GetCurvaNK(DataRow dataRow)
        {
            return new CurvaNK()
            {
                CodigoCurva = Conversor.ConverterParaInt(dataRow["CD_CURVA"]),
                NomeCurva = Conversor.ConverterParaString(dataRow["NM_CURVA"]),
                DataInicioVigencia = Conversor.ConverterParaDateTime(dataRow["DT_INICIO_VIGENCIA"]),
                DataFimVigencia = Conversor.ConverterParaDateTime(dataRow["DT_FIM_VIGENCIA"]),
                IndicePraca = Conversor.ConverterParaInt(dataRow["IC_PRACA"]),
                IndiceTipoCurva = Conversor.ConverterParaInt(dataRow["IC_TIPO_CURVA"]),
                IndiceInterpolacao = Conversor.ConverterParaInt(dataRow["IC_INTERPOLACAO"]),
                IndiceModelo = Conversor.ConverterParaInt(dataRow["IC_MODELO"]),
                IndiceCurvaJurosNK = Conversor.ConverterParaInt(dataRow["IC_CURVA_JUROS_NK"]),
                IndiceGravacaoAutomatica = Conversor.ConverterParaInt(dataRow["IC_GRV_AUTOM"]),
                NomeSaida = Conversor.ConverterParaString(dataRow["NM_SAIDA"]),
                FlagGeraCurva = Conversor.ConverterParaInt(dataRow["FL_GERA_CURVA"]),
                DescricaoFormula = Conversor.ConverterParaString(dataRow["DS_FORMULA"]),
                FlagPrimeiroFator1 = Conversor.ConverterParaInt(dataRow["FL_PRIMEIRO_FATOR_1"]),
                CodigoTipoYield = Conversor.ConverterParaString(dataRow["CD_TIPO_YIELD"]),
                NomeArquivo = Conversor.ConverterParaString(dataRow["NM_ARQUIVO"]),
                NomeDiretorio = Conversor.ConverterParaString(dataRow["NM_DIRETORIO"]),
                CodigoOperador = Conversor.ConverterParaString(dataRow["CD_OPERADOR"]),
                DataUltimaAlteracao = Conversor.ConverterParaDateTime(dataRow["DT_ULT_ALT"]),
                CodigoTipoTaxa = Conversor.ConverterParaString(dataRow["CD_TIPO_TAXA"]),
                CodigoCurvaBase = Conversor.ConverterParaInt(dataRow["CD_CURVA_BASE"])
            };
        }

        public static Informacao GetYieldInformacao(DataRow dataRow)
        {
            return new Informacao()
            {
                CodigoBACEN = Conversor.ConverterParaString(dataRow["CD_BACEN"]),
                CodigoTipoInformacao = Conversor.ConverterParaString(dataRow["CD_TIPO_INFORMACAO"]),
                CodigoTipoPUTaxa = Conversor.ConverterParaInt(dataRow["CD_TIPO_PU_TAXA"]),
                CodigoTipoTaxa = Conversor.ConverterParaString(dataRow["CD_TIPO_TAXA"]),
                CodigoYield = Conversor.ConverterParaInt(dataRow["CD_YIELD"]),
                DataAtualizacao = Conversor.ConverterParaDateTime(dataRow["DT_ATUALIZACAO"]),
                DataRegistroHistorico = Conversor.ConverterParaDateTime(dataRow["DT_REG_HISTORICO"]),
                DataVencimento = Conversor.ConverterParaDateTime(dataRow["DT_VENCIMENTO"]),
                DataUltimaAlteracao = Conversor.ConverterParaDateTime(dataRow["DT_ULT_ALT"]),
                IndiceCalculo = Conversor.ConverterParaInt(dataRow["IC_CALCULO"]),
                IndiceContigencia = Conversor.ConverterParaInt(dataRow["IC_CONTINGENCIA"]),
                MesaReferencia = Conversor.ConverterParaString(dataRow["MESREF"]),
                IndiceLiquido = Conversor.ConverterParaInt(dataRow["IC_LIQUIDO"]),
                ValorPercentualCalculo = Conversor.ConverterParaDouble(dataRow["VL_PERC_CALCULO"]),
                ValorPU = Conversor.ConverterParaDouble(dataRow["VL_PU"]),
                ValorPUTaxa = Conversor.ConverterParaDouble(dataRow["VL_PU_TAXA"]),
                ValorPUTaxa252 = Conversor.ConverterParaDouble(dataRow["VL_PU_TAXA_252"]),
                ValorSpread = Conversor.ConverterParaDouble(dataRow["VL_SPREAD"]),
                ValorTaxaForward = Conversor.ConverterParaDouble(dataRow["VL_TAXA_FORWARD"])
            };
        }
    }
}
